var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function o() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  DropMoneyView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.isStartState = !1),
        e.btn_drop_back.on(Laya.Event.CLICK, e, e.ondropMoneyBackFn),
        WebSocketService.addListener({
          caller: e,
          code: 1558,
          method: e.onLoadDropHomeData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1560,
          method: e.onLoadDrophistoryData,
        }),
        e.image_drop_da.on(Laya.Event.CLICK, e, e.onImageDropMoneyAction),
        e.image_drop_xiao.on(Laya.Event.CLICK, e, e.onImageDropMoneyAction),
        e.image_drop_dan.on(Laya.Event.CLICK, e, e.onImageDropMoneyAction),
        e.image_drop_shuang.on(Laya.Event.CLICK, e, e.onImageDropMoneyAction),
        e.image_drop_bao.on(Laya.Event.CLICK, e, e.onImageDropMoneyAction),
        (e.list_dropMoney.vScrollBarSkin = ""),
        (e.list_dropMoney.renderHandler = new Laya.Handler(
          e,
          e.updateDropMoneyItemRender
        )),
        e.btn_drop_dangqianpaihang.on(
          Laya.Event.CLICK,
          e,
          e.onDidButtonClickAction
        ),
        e.btn_drop_touzhujilu.on(Laya.Event.CLICK, e, e.onDidButtonClickAction),
        e.btn_drop_kaijiangjilu.on(
          Laya.Event.CLICK,
          e,
          e.onDidButtonClickAction
        ),
        e.btn_drop_gzsm.on(Laya.Event.CLICK, e, e.onDidClickGZAction),
        e.btn_drop_jlsm.on(Laya.Event.CLICK, e, e.onDidClickGZAction),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showDropMoneyView = function () {
        return (
          null == this.dropMoneyV && (this.dropMoneyV = new e()),
          WebSocketService.send({ c: 1558 }),
          WebSocketService.send({ c: 1560, d: { pageNum: 0 } }),
          (this.dropMoneyV.list_dropMoney.visible = !1),
          this.dropMoneyV.dealisStartView("0"),
          this.dropMoneyV
        );
      }),
      (e.prototype.onLoadDropHomeData = function (t) {
        if (0 == t.code) {
          if ("0" == t.data.s)
            this.dealisStartView("0"),
              (this.isStartState = !1),
              (this.list_dropMoney.visible = !0);
          else if ("1" == t.data.s) {
            this.dealisStartView("1"),
              (this.isStartState = !0),
              (this.label_big_totalNum.text = t.data.da + "筹码"),
              (this.label_xiao_totalNum.text = t.data.xiao + "筹码"),
              (this.label_dan_totalNum.text = t.data.dan + "筹码"),
              (this.label_shuang_totalNum.text = t.data.sh + "筹码"),
              (this.label_baozi_totalNum.text = t.data.bao + "筹码"),
              (this.list_dropMoney.visible = !1);
            var e = this.dealCompentResult(t.data.n1, t.data.n2, t.data.n3);
            this.label_drop_qishu.text =
              "上期（" +
              t.data.i +
              "）开 " +
              t.data.n1 +
              "," +
              t.data.n2 +
              "," +
              t.data.n3 +
              " " +
              e;
          }
          if (
            ((this.label_drop_paiming.text =
              "您现有" + t.data.h + "筹码，排名第" + t.data.r),
            (this.timeDiff = t.data.e),
            Laya.timer.loop(1e3, this, this.timerCountDownDropMoneyFn),
            -1 == t.data.t)
          )
            return (
              Laya.timer.clear(this, this.timerDownStartFn),
              void (this.label_drop_time_down.text = "请稍等，即将开盅...")
            );
          (this.resultDiff = t.data.t),
            Laya.timer.loop(1e3, this, this.timerDownStartFn);
        } else ToastView.toastView(t.msg);
      }),
      (e.prototype.dealisStartView = function (t) {
        "1" == t
          ? ((this.label_drop_lastState.visible = !1),
            (this.list_dropMoney.visible = !1),
            (this.label_drop_qishu.visible = !0),
            (this.label_drop_time_down.visible = !0),
            (this.label_drop_paiming.visible = !0),
            (this.image_drop_da.visible = !0),
            (this.image_drop_xiao.visible = !0),
            (this.image_drop_dan.visible = !0),
            (this.image_drop_shuang.visible = !0),
            (this.image_drop_bao.visible = !0),
            (this.btn_drop_dangqianpaihang.visible = !0),
            (this.btn_drop_touzhujilu.visible = !0),
            (this.btn_drop_kaijiangjilu.visible = !0))
          : "0" == t &&
            ((this.label_drop_lastState.visible = !0),
            (this.list_dropMoney.visible = !0),
            (this.label_drop_qishu.visible = !1),
            (this.label_drop_time_down.visible = !1),
            (this.label_drop_paiming.visible = !1),
            (this.image_drop_da.visible = !1),
            (this.image_drop_xiao.visible = !1),
            (this.image_drop_dan.visible = !1),
            (this.image_drop_shuang.visible = !1),
            (this.image_drop_bao.visible = !1),
            (this.btn_drop_dangqianpaihang.visible = !1),
            (this.btn_drop_touzhujilu.visible = !1),
            (this.btn_drop_kaijiangjilu.visible = !1));
      }),
      (e.prototype.onLoadDrophistoryData = function (t) {
        if (0 == t.code) {
          WebSocketService.send({ c: 1558 }), (this.matchArray = []);
          var e = void 0;
          if (this.currentPage >= 1) {
            if (0 == t.list.length) return void this.currentPage--;
            for (var i = 0; i < t.list.length; i++) {
              var o = t.list[i];
              this.matchArray.push(o), (this.dataSource = []);
            }
          } else (this.matchArray = t.list), (this.dataSource = []);
          (this.isloading = !1),
            0 == this.isStartState && (this.list_dropMoney.visible = !0);
          for (var a = 0; a < this.matchArray.length; a++) {
            var n = this.matchArray[a];
            (e = {
              label_match_index: { text: this.dealMatchRanking(n.r) },
              label_match_name: { text: n.n + " （" + n.h + " 筹码 ）" },
            }),
              this.dataSource.push(e);
          }
          this.list_dropMoney.dataSource = this.dataSource;
        }
      }),
      (e.prototype.timerDownStartFn = function () {
        this.resultDiff--;
        var t = 0,
          e = 0;
        e =
          (t = Math.floor(this.resultDiff / 60)) > 0
            ? Math.floor(this.resultDiff % 60)
            : Math.floor(this.resultDiff);
        var i;
        t > 0 ? (i = t + "分" + e + "秒") : e > 0 && (i = e + "秒"),
          (this.label_drop_time_down.text = i + "后开盅，买定离手啦！"),
          t <= 0 &&
            e <= 0 &&
            WebSocketService.send({ c: 1565, d: { pageNum: 0 } });
      }),
      (e.prototype.timerCountDownDropMoneyFn = function () {
        this.timeDiff--;
        var t = 0,
          e = 0,
          i = 0,
          o = 0;
        (t = Math.floor(this.timeDiff / 86400)),
          (e = Math.floor((this.timeDiff % 86400) / 3600)),
          (i = Math.floor((this.timeDiff % 3600) / 60)),
          (o = Math.floor(this.timeDiff % 60)),
          t <= 0 && e <= 0 && i <= 0 && o <= 1
            ? (Laya.timer.clear(this, this.timerCountDownDropMoneyFn),
              (this.lable_dropMoney_title.text = "请稍等..."),
              WebSocketService.send({ c: 1558 }))
            : o % 20 == 0
            ? (Laya.timer.clear(this, this.timerCountDownDropMoneyFn),
              WebSocketService.send({ c: 1558, d: null }),
              (this.lable_dropMoney_title.text = this.dealTimeDataWithParams(
                t,
                e,
                i,
                o
              )))
            : (this.lable_dropMoney_title.text = this.dealTimeDataWithParams(
                t,
                e,
                i,
                o
              ));
      }),
      (e.prototype.dealTimeDataWithParams = function (t, e, i, o) {
        var a = "0秒";
        t > 0
          ? (a = t + "天" + e + "小时" + i + "分" + o + "秒")
          : e > 0
          ? (a = e + "小时" + i + "分" + o + "秒")
          : i > 0
          ? (a = i + "分" + o + "秒")
          : o > 0 && (a = o + "秒");
        return this.isStartState
          ? a + "后结束比赛"
          : "距离撒币比赛开始还有 " + a;
      }),
      (e.prototype.dealCompentResult = function (t, e, i) {
        var o,
          a = t + e + i;
        return (
          t == e && e == i && t == i
            ? (o = "豹子")
            : 3 == a || 18 == a
            ? (o = "豹子")
            : a >= 4 && a <= 10
            ? (o = a % 2 ? "小单" : "小双")
            : a >= 11 && a <= 17 && (o = a % 2 ? "大单" : "大双"),
          o
        );
      }),
      (e.prototype.onImageDropMoneyAction = function (t) {
        "item_da" == t.target.name
          ? DropMoneyDetailDialog.showDropMoneyDetailView("大")
          : "item_xiao" == t.target.name
          ? DropMoneyDetailDialog.showDropMoneyDetailView("小")
          : "item_dan" == t.target.name
          ? DropMoneyDetailDialog.showDropMoneyDetailView("单")
          : "item_shuang" == t.target.name
          ? DropMoneyDetailDialog.showDropMoneyDetailView("双")
          : "item_bao" == t.target.name &&
            DropMoneyDetailDialog.showDropMoneyDetailView("豹子");
      }),
      (e.prototype.updateDropMoneyItemRender = function (t, e) {
        if (!(e > this.matchArray.length)) {
          var i = t.getChildByName("label_match_index");
          i.color =
            0 == e
              ? "#FFFF00"
              : 1 == e
              ? "#c0c0c0"
              : 2 == e
              ? "#CDAF95"
              : "#FFFFFF";
        }
      }),
      (e.prototype.dealMatchRanking = function (t) {
        return "1" == t ? "冠军" : "2" == t ? "亚军" : "3" == t ? "季军" : t;
      }),
      (e.prototype.onLoadMoreData = function (t) {
        var e = t / this.list_dropMoney.scrollBar.max,
          i = new Date(),
          o = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (o = !0),
          1 == e && 0 == this.isloading && o)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({
              c: 1560,
              d: { pageNum: this.currentPage },
            }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (e.prototype.onDidButtonClickAction = function (t) {
        if ("item_dqph" == t.target.name) {
          var e = DropMoneyHistoryView.showDropHistoryView("11");
          (e.y = 0), Laya.stage.addChild(e);
        } else if ("item_kjjl" == t.target.name) {
          var i = DropMoneyHistoryView.showDropHistoryView("13");
          (i.y = 0), Laya.stage.addChild(i);
        } else if ("item_tzjl" == t.target.name) {
          var o = DropMoneyHistoryView.showDropHistoryView("12");
          (o.y = 0), Laya.stage.addChild(o);
        }
      }),
      (e.prototype.onDidClickGZAction = function (t) {
        if ("item0" == t.target.name) {
          ((e = RulesView.showCaslRuleView("dropMoneyGZSM")).y = 0),
            Laya.stage.addChild(e);
        } else {
          var e = RulesView.showCaslRuleView("dropMoneyJLSM");
          (e.y = 0), Laya.stage.addChild(e);
        }
      }),
      (e.prototype.ondropMoneyBackFn = function () {
        Laya.timer.clear(this, this.timerCountDownDropMoneyFn),
          Laya.timer.clearAll(this),
          this.removeSelf();
      }),
      e
    );
  })(ui.ChallengeBattle.DropMoneyViewUI);
